﻿@using MvcFileUploader.HtmlHelper
@using MvcFileUploader.Models
@model PhotoBlog.Core.Models.Album
@{
    ViewBag.Title = "Редактирование альбома";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="form-horizontal">
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.AlbumId)
        @Html.HiddenFor(model => model.UserId)
        <div class="form-group">
            @Html.LabelFor(model => model.AlbumName, "Название", new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.AlbumName)
                @Html.ValidationMessageFor(model => model.AlbumName)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, "Описание", new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextAreaFor(model => model.Description)
                @Html.ValidationMessageFor(model => model.Description)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Hide, "Скрыть", new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Hide)
                @Html.ValidationMessageFor(model => model.Hide)
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Сохранить" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <div class="well">
            @(
 Html.MvcFileUpload()
        .UploadAt(Url.Action("UploadFile", "Photos", new { id = Model.AlbumId }))
        .UIStyle(UploadUI.Bootstrap)
        .WithFileTypes(@"/(\.|\/)(jpe?g|png)$/i")
        .WithMaxFileSize(10000000)
        .AddFormField("entityId", Guid.NewGuid().ToString())
        .RenderInline("_MvcFileupload")
            )
        </div>
    </div>
</div>



<div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <ul class="list-unstyled pull-left">
            <li><a href="@Url.Action("UploadFiles", "Photos", new { id = Model.AlbumId })" class="text-center">Старый загрузчик фотографий</a></li>
        </ul>
        <div class="clearfix"></div>
    </div>
</div>

<div class="form-group">
    <div class="col-md-offset-2">
        @{
            var i = 0;
            var countPhotos = 0;
        }
        @foreach (var photo in Model.Photos)
        {
            countPhotos++;
            if (i == 4)
            {
                <div class="clearfix"></div>
                <br />
                i = 0;
                if (countPhotos == Model.Photos.Count())
                {
                    var arg0 = Request.Url != null ? Request.Url.Authority : "";
                    var url = string.Format("http://{0}/{1}/T/{2}", arg0, photo.Path, photo.PhotoName);

                    <div class="col-lg-3 relative">
                        <div class="top" style="height: 200px;background-image: url('@url');background-position: center; -ms-background-size: cover; background-size: cover;background-repeat: no-repeat;">
                        </div>
                        <div class="top" style="position: absolute; right: 20px; top: 5px;">
                            @using (Html.BeginForm("Delete", "Photos", new { id = photo.PhotoId, albumId = photo.AlbumId }, FormMethod.Post))
                            {
                                <input type="submit" value="x" class="btn btn-sm btn-danger" />
                            }
                        </div>
                        <div>
                            <a href="@url">ссылка</a> 
                        </div>
                    </div>
                }
            }
            else
            {
                var arg0 = Request.Url != null ? Request.Url.Authority : "";
                var url = string.Format("http://{0}/{1}/T/{2}", arg0, photo.Path, photo.PhotoName);

                <div class="col-lg-3 relative">
                    <div class="top" style="height: 200px;background-image: url('@url');background-position: center; -ms-background-size: cover; background-size: cover;background-repeat: no-repeat;">
                    </div>
                    <div class="top" style="position: absolute; right: 20px; top: 5px;">
                        @using (Html.BeginForm("Delete", "Photos", new { id = photo.PhotoId, albumId = photo.AlbumId }, FormMethod.Post))
                        {
                            <input type="submit" value="x" class="btn btn-sm btn-danger" />
                        }
                    </div>
                    <div>
                        <a href="@url">ссылка</a> 
                    </div>
                </div>
                        i++;
            }

        }
    </div>
</div>
<div class="clearfix"></div>

<div class="row">
    @Html.ActionLink("Назад", "Index")
</div>
